MsgN("\n----------------------------------------")
MsgN("-- MadDog's Resource Systems Loading")

CreateConVar( "maddogs_resource_systems", "1", FCVAR_NOTIFY )
CreateConVar( "maddogs_resource_systems_update_time", "1", FCVAR_NOTIFY )
CreateConVar( "maddogs_resource_systems_debug", "0", FCVAR_NOTIFY )

CreateConVar( "maddogs_resource_systems_lowGenerate", "490", FCVAR_NOTIFY )
CreateConVar( "maddogs_resource_systems_highGenerate", "500", FCVAR_NOTIFY )

CreateConVar( "maddogs_resource_systems_lowConsume", "490", FCVAR_NOTIFY )
CreateConVar( "maddogs_resource_systems_highConsume", "500", FCVAR_NOTIFY )


--holds the entire Resource System
RS = {}
RS.Version = "1.01"

RS.IsEnabled = function()
	--MadDogs Base is required
	return (MD && MD.IsEnabled() && tonumber(GetConVarNumber("maddogs_resource_systems")) == 1)
end

RS.NodeUpdateTime = function()
	return tonumber(GetConVarNumber("maddogs_resource_systems_update_time") or 1)
end

RS.Debug = function()
	return (tonumber(GetConVarNumber("maddogs_resource_systems_debug")) == 1)
end

--include the shared files
for _, file in pairs(file.FindInLua("maddogs_resource_systems/shared/*.lua")) do
	MsgN("--\t" .. file .. " loaded.")
	IncludeClientFile( "maddogs_resource_systems/shared/" .. file )

	if SERVER then include( "maddogs_resource_systems/shared/" .. file ) end
end

--server side calls
if (SERVER) then
	--include this file
	AddCSLuaFile("autorun/maddogs_resource_systems.lua")

	--get all server side files
	for _, file in pairs(file.FindInLua("maddogs_resource_systems/server/*.lua")) do
		MsgN("--\t" .. file .. " loaded.")
		include( "maddogs_resource_systems/server/" .. file )
	end

	RunConsoleCommand("sv_tags", (GetConVarString("sv_tags") or "")..",maddogs_resource_systems")
end



--load all client files
for _, file in pairs(file.FindInLua("maddogs_resource_systems/client/*.lua")) do
	MsgN("--\t" .. file .. " loaded.")
	IncludeClientFile( "maddogs_resource_systems/client/" .. file )
end

--ok now include the devices
if SERVER then include("maddogs_resource_systems/mdrs_devices.lua") end
IncludeClientFile("maddogs_resource_systems/mdrs_devices.lua")

MsgN("--\tmdrs_devices.lua loaded.")

MsgN("-- Done.")
MsgN("----------------------------------------\n")